import { createI18n } from 'vue-i18n';

import { useAppStoreHook } from '@/stores/index';
import zhCN from './cn.json';
import enUS from './en-US.json';
// vant

export type Typelanguage = 'en-US' | 'zh-CN';
type MessageSchema = typeof enUS;

const appStore = useAppStoreHook();

export const I18nMessages = {
    'zh-CN': zhCN,
    'en-US': enUS,
};

const i18n = createI18n<[MessageSchema], Typelanguage>({
    legacy: false,
    globalInjection: true,
    locale: appStore.language,
    fallbackLocale: 'zh-CN',
    messages: I18nMessages,
});

export default i18n;
